#ifndef TRANSMISSIONINTER_H
#define TRANSMISSIONINTER_H

#include "paramnonstandard485.h"
#include <QObject>
class TransmissionInter : public QObject {
    Q_OBJECT
public:
    enum TransAction {
        Start_Forward = 0,  //启动正转，传入
        Start_Reverse = 1,  //启动反转，传出
        Stop          = 2,  //停止，
                            //        Brak          = 3,  //刹车
                            //        NO_Brak       = 4,  //松刹车
    };
    enum TransMissionState {
        Start_Forward_ING = 0,  //启动正转，传入
        Start_Reverse_ING = 1,  //启动反转，传出
        Stop_ING          = 2,  //停止，
        Error             = 3,  //错误
    };
    enum TransMissionErrorCode {
        Er00 = 0,   //无
        Er01 = 1,   // DMK_堵转报警,    TB_超速
        Er02 = 2,   // DMK_硬件过流报警  TB_过压
        Er03 = 3,   // DMK_霍尔报警,    TB_MOS管过流
        Er04 = 4,   // DMK_欠压报警,    TB_过流
        Er05 = 5,   // DMK_过压报警,    TB_欠压
        Er06 = 6,   // DMK_模块故障,    TB_霍尔错误
        Er07 = 7,   // DMK_基准故障,    TB_堵转
        Er08 = 8,   // DMK_过载报警,    TB_过温
        Er09 = 9,   // DMK_超速报警,    TB_两种以上故障
        Er10 = 10,  // DMK_峰值过流报警
        Er11 = 11,  // DMK_均值过流报警
        Er12 = 12,  // DMK_IGBT故障报警
        Er13 = 13,  // DMK_驱动器过热报警
        Er14 = 14,  // DMK_电机缺相报警
        Er15 = 15,  // DMK_通讯故障报警
        Er16 = 16,  // DMK_堵转报警
    };
    struct TransMissionData {
        uchar                 device_address;
        TransAction           trans_action;
        TransMissionState     state;
        TransMissionErrorCode errorCode;
    };

    enum EnumBattery {
        /**
         * @brief  最大电压
         */
        MAX_VOLTAGE = 4,

        /**
         * @brief  最小电压
         */
        MIN_VOLTAGE = 6,

        /**
         * @brief  最大电压编号
         */
        MAX_VOLTAGE_NUM = 8,

        /**
         * @brief  最小电压编号
         */
        MIN_VOLTAGE_NUM = 10,
        /**
         * @brief  电芯最高温度
         */
        MAX_TEMP_TEMP_EXCURSION_VALUE = 12,
        /**
         * @brief  电芯最低温度
         */
        MIN_TEMP_TEMP_EXCURSION_VALUE = 14,
        /**
         * @brief  最高温度编号
         */
        MAX_TEMP_EXCURSION_NUM = 16,
        /**
         * @brief  最高温度编号
         */
        MIN_TEMP_EXCURSION_NUM = 18,
        /**
         * @brief  单体1 电压
         */
        CELL1_VOLTAGE = 20,
        /**
         * @brief  单体2 电压
         */
        CELL2_VOLTAGE = 22,
        /**
         * @brief  单体3 电压
         */
        CELL3_VOLTAGE = 24,
        /**
         * @brief  单体4 电压
         */
        CELL4_VOLTAGE = 26,
        /**
         * @brief  单体5 电压
         */
        CELL5_VOLTAGE = 28,
        /**
         * @brief  单体6 电压
         */
        CELL6_VOLTAGE = 30,
        /**
         * @brief  单体7 电压
         */
        CELL7_VOLTAGE = 32,
        /**
         * @brief  单体8 电压
         */
        CELL8_VOLTAGE = 34,
        /**
         * @brief  单体9 电压
         */
        CELL9_VOLTAGE = 36,
        /**
         * @brief  单体10 电压
         */
        CELL10_VOLTAGE = 38,
        /**
         * @brief  单体11 电压
         */
        CELL11_VOLTAGE = 40,
        /**
         * @brief  单体12 电压
         */
        CELL12_VOLTAGE = 42,
        /**
         * @brief  单体13 电压
         */
        CELL13_VOLTAGE = 44,
        /**
         * @brief  单体14 电压
         */
        CELL14_VOLTAGE = 46,
        /**
         * @brief  单体15 电压
         */
        CELL15_VOLTAGE = 48,
        /**
         * @brief  单体16 电压
         */
        CELL16_VOLTAGE = 50,
        /**
         * @brief  单体17 电压
         */
        CELL17_VOLTAGE = 52,
        /**
         * @brief  单体18 电压
         */
        CELL18_VOLTAGE = 54,
        /**
         * @brief  单体19 电压
         */
        CELL19_VOLTAGE = 56,
        /**
         * @brief  单体20 电压
         */
        CELL20_VOLTAGE = 58,
        /**
         * @brief  单体21 电压
         */
        CELL21_VOLTAGE = 60,
        /**
         * @brief  单体22 电压
         */
        CELL22_VOLTAGE = 62,
        /**
         * @brief  单体23 电压
         */
        CELL23_VOLTAGE = 64,
        /**
         * @brief  单体24 电压
         */
        CELL24_VOLTAGE = 66,
        /**
         * @brief  单体25 电压
         */
        CELL25_VOLTAGE = 68,
        /**
         * @brief  单体26 电压
         */
        CELL26_VOLTAGE = 70,
        /**
         * @brief  单体27 电压
         */
        CELL27_VOLTAGE = 72,
        /**
         * @brief  单体28 电压
         */
        CELL28_VOLTAGE = 74,
        /**
         * @brief  单体29 电压
         */
        CELL29_VOLTAGE = 76,
        /**
         * @brief  单体30 电压
         */
        CELL30_VOLTAGE = 78,
        /**
         * @brief  单体31 电压
         */
        CELL31_VOLTAGE = 80,
        /**
         * @brief  单体32 电压
         */
        CELL32_VOLTAGE = 82,
        /**
         * @brief  探针1温度
         */
        TEMPERATURE1_TEMP_EXCURSION_VALUE = 84,
        /**
         * @brief  探针2温度
         */
        TEMPERATURE2_TEMP_EXCURSION_VALUE = 86,
        /**
         * @brief  探针3温度
         */
        TEMPERATURE3_TEMP_EXCURSION_VALUE = 88,
        /**
         * @brief  探针4温度
         */
        TEMPERATURE4_TEMP_EXCURSION_VALUE = 90,
        /**
         * @brief  探针5温度
         */
        TEMPERATURE5_TEMP_EXCURSION_VALUE = 92,
        /**
         * @brief  探针6温度
         */
        TEMPERATURE6_TEMP_EXCURSION_VALUE = 94,
        /**
         * @brief  SOC
         */
        SOC = 96,
        /**
         * @brief  SOH
         */
        SOH = 98,
        /**
         * @brief  充电SOP
         */
        PackChaCur = 100,
        /**
         * @brief  放电SOP
         */
        PackDisCur = 102,
        /**
         *@brief 总电流
         */
        MEASURING_CURRENT = 104,
        /**
         *@brief 总电压
         */
        ALL_CELL_VOLTAGE = 106,
        /**
         *@brief 短路次数
         */
        gstcSysVar_ShortTime = 108,
        /**
         *@brief 充电次数
         */
        gstcSysVar_ChargingTime = 110,
        /**
         *@brief 循环次数
         */
        gstcSysVar_CyclesTime = 112,
        /**
         *@brief 充电总时间
         */
        gstcSysVar_ChargeTime = 114,
        /**
         *@brief 放电总时间
         */
        gstcSysVar_DischargeTime = 118,
        /**
         *@brief 最大充电间隔时间
         */
        gstcSysVar_MaxChargeInterval = 122,

        /**
         *@brief 最大放电间隔时间
         */
        gstcSysVar_MaxDischargeInterval = 126,
        /**
         *@brief 均衡状态
         */
        gstcSysVar_BalancehState = 130,
        /**
         *@brief 电芯串工作状态
         */
        gstcSysVar_CellWorkState = 134,

        /**
         *@brief 故障状态
         */
        gstcSysVar_unSwProtectStatus_word = 138
    };

public:
    explicit TransmissionInter( QObject* parent = nullptr, ParamNonStandard485* param = nullptr );
    //     ~TransmissionInter()                = 0;
    virtual void init( QList< QByteArray >* writeList, int state_ID )                                       = 0;
    virtual void onAddReadData( QList< QByteArray >* readList, int state_ID )                               = 0;
    virtual void onAddWriteData( QList< QByteArray >* writeList, const TransMissionData& transMissionData ) = 0;
    virtual void onReadHandler( const QByteArray& readByte ) = 0;
    TransMissionData getTransMissionData( uchar device_address, TransMissionState state, TransAction trans_action );
    TransMissionData getTransMissionData( uchar device_address, TransMissionState state, TransMissionErrorCode core );
    void setParam( ParamNonStandard485* param );

protected:
    ParamNonStandard485* param_p = nullptr;

signals:
    void sigTransmissionError( const uchar deviceAddress );
    void sigTransmissionState( const TransMissionData data );
};

#endif  // TRANSMISSIONINTER_H
